/*
 * Created on Feb 12, 2008
 */
package maxygen;

import java.awt.Rectangle;

/**
 * For identifying regions of a patcher window to grab to a JPEG file.
 * 
 * @author martinrobinson
 */
class Region
{
    String name;
    private String caption;
    int x, y, w, h;
    private String brief;
    private String detail;
    private engine e;
    
    static final boolean LOCKED = true;
    static final boolean UNLOCKED = false;
    
    Region(engine e, String name, int x, int y, int w, int h)
    {
        this.name = name;
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.e = e;
    }
    
    String getAnchor()
    {
        return StringUtility.underscoreNonAlphaNum(caption);
    }
    
    String getBrief()
    {
        return brief;
    }
    
    String getDetail()
    {
        return detail;
    }
    
    String getCaption()
    {
        return caption;
    }
    
    void setBrief(String brief)
    {
        this.brief = brief == null ? "" : brief;
        String caption = StringUtility.splitAtCaption(brief);
        if(caption!=null)
            this.caption = caption;
        else
            this.caption = name;
    }
    
    void setDetail(String detail)
    {
        this.detail = detail == null ? "" : detail;
    }
    
    Rectangle getRect()
    {
        return new Rectangle(x,y,w,h);
    }
    
    PatcherWrapper getPatcher()
    {
        return new PatcherWrapper(e.getParentPatcher());
    }
    
    engine getEngine()
    {
        return e;
    }
}